package com.ykfa.tess4j;

import java.io.File;

import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

/**
 * @author yingkf
 * @date 2023年10月23日10:57:55
 */
public class TesseractTest {
    private static String dataPath = "/home/tungchi/IdeaProjects/java-practice/third-util/src/main/resources/dataPath/tessdata_fast";
    private static String testPath = "/home/tungchi/IdeaProjects/java-practice/third-util/src/main/resources/testFile/";

    public static void main(String[] args) throws TesseractException {
        Tesseract tesseract = new Tesseract();
        // 设置训练数据文件夹路径
        tesseract.setDatapath(dataPath);
        // 设置为中文简体
        tesseract.setLanguage("chi_sim");
        tesseract.setTessVariable("user_defined_dpi", "800");

//        File file = new File(testPath+"外国人永久居留身份证.png");
//        String rs = tesseract.doOCR(file);
//        System.out.println(rs);


//        File file = new File(testPath+"身份证.png");
//        String rs = tesseract.doOCR(file);
//        System.out.println(rs);

        File file = new File(testPath + "热点新闻.png");
        String rs = tesseract.doOCR(file);
        System.out.println(rs);
    }
}
